package com.feonix.common.util;


import java.io.File;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Iterator;
import java.util.List;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Properties {
	
	private static final Log logger = LogFactory.getLog(Properties.class);
	private PropertiesConfiguration propertiesConfiguration;

	public Properties(String paramString) {
		try {
			this.propertiesConfiguration = new PropertiesConfiguration(paramString);
		} catch (ConfigurationException configurationException) {
			logger.error("PropertiesUtil(String)", configurationException);
		}
	}

	public void addProperty(String paramString, Object paramObject) {
		this.propertiesConfiguration.addProperty(paramString, paramObject);
	}

	public void removeProperty(String paramString) {
		this.propertiesConfiguration.clearProperty(paramString);
	}

	public void save() {
		try {
			this.propertiesConfiguration.save();
		} catch (ConfigurationException configurationException) {
			logger.error("saveProperties()", configurationException);
		}
	}

	public void saveAs(File paramFile) {
		try {
			this.propertiesConfiguration.save(paramFile);
		} catch (ConfigurationException configurationException) {
			logger.error("saveAsProperties(File)", configurationException);
		}
	}

	public BigDecimal getBigDecimal(String paramString) {
		return this.propertiesConfiguration.getBigDecimal(paramString);
	}

	public BigInteger getBigInteger(String paramString) {
		return this.propertiesConfiguration.getBigInteger(paramString);
	}

	public Boolean getBoolean(String paramString) {
		Boolean bl = null;
		if (this.propertiesConfiguration.containsKey(paramString)) {
			bl = Boolean.valueOf(this.propertiesConfiguration.getBoolean(paramString));
		}
		return bl;
	}

	public byte getByte(String paramString) {
		return this.propertiesConfiguration.getByte(paramString);
	}

	public double getDouble(String paramString) {
		return getDouble(paramString, 0.0D);
	}

	public double getDouble(String paramString, double paramDouble) {
		return this.propertiesConfiguration.getDouble(paramString, paramDouble);
	}

	public float getFloat(String paramString) {
		return getFloat(paramString, 0.0F);
	}

	public float getFloat(String paramString, float paramFloat) {
		return this.propertiesConfiguration.getFloat(paramString, paramFloat);
	}

	public int getInt(String paramString) {
		return getInt(paramString, 0);
	}

	public int getInt(String paramString, int paramInt) {
		return this.propertiesConfiguration.getInt(paramString, paramInt);
	}

	public long getLong(String paramString) {
		return getLong(paramString, 0L);
	}

	public long getLong(String paramString, long paramLong) {
		return this.propertiesConfiguration.getLong(paramString, paramLong);
	}

	public short getShort(String paramString) {
		short s = 0;
		return getShort(paramString, s);
	}

	public short getShort(String paramString, short paramShort) {
		return this.propertiesConfiguration.getShort(paramString, paramShort);
	}

	public String getString(String paramString) {
		return getString(paramString, "");
	}

	public String getString(String paramString1, String paramString2) {
		return this.propertiesConfiguration.getString(paramString1, paramString2);
	}

	public List<Object> getList(String paramString) {
		return this.propertiesConfiguration.getList(paramString);
	}

	public boolean containsKey(String paramString) {
		return this.propertiesConfiguration.containsKey(paramString);
	}

	public Iterator<String> getKeys() {
		return this.propertiesConfiguration.getKeys();
	}

	public boolean isEmpty() {
		return this.propertiesConfiguration.isEmpty();
	}

	public void clear() {
		this.propertiesConfiguration.clear();
	}

	public void setProperty(String paramString, Object paramObject) {
		this.propertiesConfiguration.setProperty(paramString, paramObject);
	}

	public Iterator<String> getKeys(String paramString) {
		return this.propertiesConfiguration.getKeys(paramString);
	}

}
